SET PROC TO SOSPRO
SET PROC TO BOXPROC
SET DELE ON
F1='PATIENT.dbf'
F2='PAT_HL.DBF'
F3='EMPLOYEE.DBF'
F4='FAMILY.DBF'

F21='PAT_HL'
F31='EMPLOYEE'
F41='FAMILY'

SELE 1
SET exclu on
USE &DR1&F1
IF NET_USE('&DR1&F1',.T.,'1',10)
   DELE ALL FOR pat_filcod=space(6) .OR. (pat_name=space(16) .and. pat_f_name=space(16)) .OR. (left(pat_name,3)='XXX'.and. .not. healthline)
ENDIF
UNLOCK

SET exclu on
CLOSE DATA
SELE 1
SET EXCLU On
USE &DR1&F2
IF NET_USE('&DR1&F2',.T.,"1",10)
   ZAP
   APPE FROM &DR1&F1 FOR HEALTHLINE
   index on pat_name+pat_f_name to &DR1&f21
ENDIF
UNLOCK

clos all
SELE 1
SET exclu on
USE &DR1&F3
IF NET_USE('&DR1&F3',.T.,"1",10)
   ZAP
   APPE FROM &DR1&F1 FOR AEASOS_PER
   index on pat_name+pat_f_name to &DR1&f31
ENDIF
UNLOCK

clos all
SELE 1
SET exclu on
USE &DR1&F4
IF NET_USE('&DR1&F4',.T.,"1",10)
   ZAP
   APPE FROM &DR1&F1 FOR AEASOS_FAM
   index on pat_name+pat_f_name to &DR1&f41
ENDIF
UNLOCK

F1='IN_PAT'
F2='NON_INVP'

SELE 1
SET exclu on
USE &DR1&F1
IF NET_USE('&DR1&F1',.T.,"1",10)
   PACK
ENDIF
UNLOCK

clos data
SELE 1
USE &DR1&F2
IF NET_USE('&DR1&F2',.T.,"1",10)
   APPE FROM &DR1&F1
ENDIF
UNLOCK

CLOS DATA
SELE 1
SET exclu on
use &DR1&f1
IF NET_USE('&DR1&F1',.T.,"1",10)
    ZAP
ENDIF
UNLOCK

SET exclu on
CLOS ALL
return
